package com.google.code.ptrends.locators.implementations;

import org.apache.poi.ss.formula.eval.NotImplementedException;

import com.google.code.ptrends.entities.SupplierConfiguration;
import com.google.code.ptrends.locators.Locator;
import com.google.code.ptrends.locators.LocatorFactory;

public class LocatorFactoryImpl implements LocatorFactory {

	@Override
	public Locator createLocator(final SupplierConfiguration cfg) {
		Locator locator;
		final String sourceLocation = cfg.getSourceLocation();

		switch (cfg.getSourceCategory()) {
		case HTTP:
			locator = new HTTPLocator();
			break;
		case FTP:
			locator = new FTPLocator();
			break;
		case URI:
			locator = new URILocator(sourceLocation);
			break;
		case FILE:
			locator = new FileLocator(sourceLocation);
			break;
		default:
			throw new NotImplementedException("No category");			
		}
		return locator;
	}

}
